 package sza.oracle.apps.ap.oie.webui;
 
 import oracle.apps.ap.oie.server.ReceiptBasedLinesVORowImpl;
 import oracle.apps.ap.oie.webui.HeaderCO;
 import oracle.apps.ap.oie.webui.NavigationUtility;
 import oracle.apps.fnd.common.VersionInfo;
 import oracle.apps.fnd.framework.OAApplicationModule;
 import oracle.apps.fnd.framework.OAViewObject;
 import oracle.apps.fnd.framework.webui.OAPageContext;
 import oracle.apps.fnd.framework.webui.beans.OAWebBean;
 import oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean;
 import oracle.apps.fnd.framework.webui.beans.nav.OALinkBean;
 import oracle.jbo.Row;
 import sza.oracle.apps.ap.oie.server.ExpenseTemplatesAdditionalVOImpl;
 import sza.oracle.apps.ap.oie.utility.SzaOIEUtil;
 
 public class SzaHeaderCO extends HeaderCO
 {
   public static final String RCS_ID = "$Header$";
   public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header$", "%packagename%");
 
   public void processRequest(OAPageContext pageContext, OAWebBean webBean)
   {
     String LogMessage = "";
     String LogFunction = "";
     LogFunction = "SZA SzaHeaderCO.processRequest";
 
     LogMessage = "SZA SzaHeaderCO.processRequest - Start";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     pageContext.putTransactionValue("IsInvoiceUploadRequired", "N");
 
     pageContext.putTransactionValue("IsExpenseRecognitionReport", "N");
 
     super.processRequest(pageContext, webBean);
 
     String TemplateId = (String)pageContext.getTransactionValue("TemplateId");
 
     LogMessage = "SZA SzaHeaderCO.processRequest - TemplateId:" + TemplateId.toString();
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String ExpTemplate = pageContext.getParameter("ExpTemplate");
     LogMessage = "SZA SzaHeaderCO.processRequest - ExpTemplate:" + ExpTemplate;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     if ((ExpTemplate != null) && (ExpTemplate != ""))
     {
       TemplateId = ExpTemplate;
     }
     OAApplicationModule am = pageContext.getApplicationModule(webBean);
     ExpenseTemplatesAdditionalVOImpl expensetemplatesadditionalvo = (ExpenseTemplatesAdditionalVOImpl)am.findViewObject("ExpenseTemplatesAdditionalVO1");
 
     if (expensetemplatesadditionalvo != null)
     {
       LogMessage = "Found VO ExpenseTemplatesAdditionalVO1. This means we have re-entered the page";
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
     }
     else
     {
       LogMessage = "CAN NOT FIND VO ExpenseTemplatesAdditionalVO1.";
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
       expensetemplatesadditionalvo = (ExpenseTemplatesAdditionalVOImpl)am.createViewObject("ExpenseTemplatesAdditionalVO1", "sza.oracle.apps.ap.oie.server.ExpenseTemplatesAdditionalVO");
     }
 
     if (expensetemplatesadditionalvo != null)
     {
       String WhereClause = " 1 = 1 ";
       WhereClause = WhereClause + " and expense_report_id = nvl(:1,'-99') ";
       expensetemplatesadditionalvo.setWhereClauseParams(null);
       expensetemplatesadditionalvo.setWhereClause(WhereClause);
       expensetemplatesadditionalvo.setWhereClauseParam(0, TemplateId);
 
       expensetemplatesadditionalvo.executeQuery();
 
       LogMessage = "SZA SzaHeaderCO.processRequest - Expense Report Template Additional - QuerySql:" + expensetemplatesadditionalvo.getQuery();
 
       SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
       String InvoiceImportFlag = "";
       String Attribute1 = "";
       if (expensetemplatesadditionalvo.getRowCount() > 0)
       {
         InvoiceImportFlag = (String)expensetemplatesadditionalvo.first().getAttribute("InvoiceImportFlag");
 
         LogMessage = "SZA SzaHeaderCO.processRequest - Expense Report Template InvoiceImportFlag - Attribute2:" + InvoiceImportFlag;
 
         SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
         Attribute1 = (String)expensetemplatesadditionalvo.first().getAttribute("Attribute1");
 
         LogMessage = "SZA SzaHeaderCO.processRequest - Expense Report Template InvoiceImportFlag - Attribute1:" + Attribute1;
 
         SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
       }
 
       if ("Y".equalsIgnoreCase(Attribute1))
       {
         pageContext.putTransactionValue("IsExpenseRecognitionReport", "Y");
       }
       else
       {
         pageContext.putTransactionValue("IsExpenseRecognitionReport", "N");
       }
 
       if ("true".equalsIgnoreCase(InvoiceImportFlag))
       {
         OALinkBean SzaInvoiceImportLink = (OALinkBean)webBean.findIndexedChildRecursive("SzaInvoiceImportLink");
 
         if (SzaInvoiceImportLink != null)
         {
           SzaInvoiceImportLink.setRendered(true);
           pageContext.putTransactionValue("IsInvoiceUploadRequired", "Y");
 
           SzaInvoiceImportLink.setText(SzaInvoiceImportLink.getText());
         }
         else
         {
           SzaInvoiceImportLink.setRendered(false);
         }
       }
     }
 
     LogMessage = "SZA SzaHeaderCO.processRequest - End";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
   }
 
   public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
   {
     String LogMessage = "";
     String LogFunction = "";
     LogFunction = "SZA SzaHeaderCO.processFormRequest";
 
     LogMessage = "SZA SzaHeaderCO.processFormRequest - Start";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     OAApplicationModule am = pageContext.getApplicationModule(webBean);
 
     OAPageLayoutBean pageLayout = pageContext.getPageLayoutBean();
 
     SzaOIEUtil.printContextParameter(pageContext, webBean);
 
     SzaOIEUtil.printContextTransaction(pageContext, webBean);
 
     SzaOIEUtil.printContextSession(pageContext, webBean);
 
     String TemplateId = (String)pageContext.getTransactionValue("TemplateId");
 
     LogMessage = "SZA SzaHeaderCO.processFormRequest - TemplateId:" + TemplateId.toString();
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String CurrentPage = NavigationUtility.getCurrentPage(pageContext);
     LogMessage = "SZA SzaButtonsCO.processFormRequest - CurrentPage:" + CurrentPage;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String event = pageContext.getParameter("event");
     LogMessage = "SZA SzaHeaderCO.processFormRequest - event:" + event;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     String source = pageContext.getParameter("source");
     LogMessage = "SZA SzaHeaderCO.processFormRequest - source:" + source;
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
     if (("GeneralInformationPG".equalsIgnoreCase(CurrentPage)) && ("OIEChangeExpTemplate".equals(event)) && ("ExpTemplate".equals(source)))
     {
       OAViewObject LineVo = (OAViewObject)am.findViewObject("CashAndOtherLinesVO");
 
       if (LineVo != null)
       {
         LineVo.first();
 
         LogMessage = "SZA SzaHeaderCO.processFormRequest - Line Loop - Start";
 
         SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
 
         while (LineVo.hasNext())
         {
           ReceiptBasedLinesVORowImpl receiptBasedLinesVORowImpl = (ReceiptBasedLinesVORowImpl)LineVo.next();
 
           Row row = LineVo.getCurrentRow();
 
           row.setAttribute("WebParameterId", "");
 
           row.setAttribute("ItemDescription", " ");
 
           LineVo.next();
         }
         LineVo.reset();
         LogMessage = "SZA SzaHeaderCO.processFormRequest - Line Loop - End";
 
         SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
       }
 
     }
 
     super.processFormRequest(pageContext, webBean);
 
     LogMessage = "SZA SzaHeaderCO.processFormRequest - End";
 
     SzaOIEUtil.cmlinLog(pageContext, LogFunction, LogMessage);
   }
 }



